package com.itbaizhan.security;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.gson.JsonSerializer;
import com.itbaizhan.result.BaseResult;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.bson.json.JsonObject;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import java.io.IOException;

/**
 * @author spf
 * @date 2024/3/6
 * @time 17:26
 */
public class MyLoginSuccessHandler implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        response.setContentType("text/json;charset=utf-8");
        BaseResult result = new BaseResult(200, "登录成功", null);
        response.getWriter().write(result.toString());    }
}
